package com.wyh.cloud.controller;

import com.wyh.cloud.service.impl.PaymentServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.CommonResult;
import pojo.Payment;

import java.util.List;

/**
 * @author wyh
 * @version 1.0
 * @date 2021/11/26 10:13
 */
@RestController
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentServiceImpl paymentService;

    @Value("${server.port}")
    private String ServerPort;

    @GetMapping(value = "/payment/findAll")
    public CommonResult findAll() {
        List<Payment> payments = paymentService.findAll();
        log.info(ServerPort + "*******查用户成功" + payments);
        if (payments.size() > 0) {
            return new CommonResult(200, "success " + ServerPort, payments);
        }
        return new CommonResult(500, "error", null);
    }
}
